import sys,time,msgpack,pickle,cPickle,random

test_list = []
i = 0
while i<100000:
    test_list.append(random.randrange(1,100000))
    i += 1
print len(test_list)
print "common len(serialize) = %s"%len(cPickle.dumps(test_list,0))
print "compress len(serialize) = %s"%len(cPickle.dumps(test_list,1))
print "common len(serialize) = %s"%len(msgpack.dumps(test_list))
##------------------------------------------------------------------------
#results = {}
#time_start = time.time()
#for i in range(1,1000000):
#        results[i] = cPickle.dumps(test_list,1)
#time_mid_1 = time.time()
#print "cPickle dumps eats %s s"%str(time_mid_1-time_start)
#
#for i in range(1,1000000):
#    cPickle.loads(results[i])
#time_mid_2 = time.time()
#print "cPickle loads eats %s s"%str(time_mid_2-time_mid_1)
#
##------------------------------------------------------------------------
#results = {}
#time_start = time.time()
#for i in range(1,1000000):
#    results[i] = msgpack.dumps(test_list)
#time_mid_1 = time.time()
#print "msgpack pack eats %s s"%str(time_mid_1-time_start)
#
#for i in range(1,1000000):
#    msgpack.loads(results[i])
#time_mid_2 = time.time()
#print "msgpack unpack eats %s s"%str(time_mid_2-time_mid_1)
